fix: add days ("d") unit to parse_duration#55
Open
NONONO3199 wants to merge 1 commit into
Open
Conversation
The _TOKEN regex already accepted "d" but _UNITS was missing the "d" key, causing day values to be silently ignored. - Add "d": 86400 to _UNS dict - Add test_days and test_days_combined test cases - Update docstring with day example Fixes tine1117#1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The
parse_durationfunction accepts"d"as valid input (the regex matches it), but silently ignores the day value because_UNITSis missing the"d"key.parse_duration("1d")returns 0 instead of 86400parse_duration("2d4h")returns 14400 instead of 187200Fix
"d": 86400to the_UNSdict induration_utils.pytest_daysandtest_days_combinedtest casesTests
All 9 tests pass:
Fixes #1